package com.game.euchre;

public class Card
{
  public int suit, rank, trump = 0;
int value;
  public static String[] suits = { "h", "d", "s", "c" };
  public static String[] ranks  = { "9", "10", "Jack", "Queen", "King", "Ace", 
	  								 	"Trump 9", "Trump 10", "Trump Queen", "TrumpKing", 
	  								 	"Trump Ace", "Trump LeftBower", "Trump RightBower"};
	 
  public Card(int suit, int rank, int trump, int value)
    {
	   this.suit = suit;
	   this.rank = rank;
       this.trump = trump;
       this.value = value;
    }
 
  public @Override String toString()
    {
      return ranks[rank] + " of " + suits[suit];
    }
	 
  public int getRank()
   {
     switch(rank)
         {  
            case 0: return 1;
            case 1: return 2;
            case 2: return 3;
            case 3: return 4;
            case 4: return 5;
            case 5: return 6;
            case 6: return 7;
            case 7: return 8;
            case 8: return 9;
            case 9: return 10;
            case 10: return 11;
            case 11: return 12;
            default: return 0;
         }  
   }
  
  // implement value
  public void changeTrump(Card hand[], int i)
  {
	hand[i].trump = 1;
  }
  
  public void changeSuit(Card hand[], int i)
  {
	  if(hand[i].value == 8)
	  {
		  hand[i].suit = 0;
		  hand[i].rank = 11;
	  }
	  if(hand[i].value == 2)
	  {
		  hand[i].suit = 1;
		  hand[i].rank = 11;
	  }
	  if(hand[i].value == 20)
	  {
		  hand[i].suit = 2;
		  hand[i].rank = 11;
	  }
	  if(hand[i].value == 14)
	  {
		  hand[i].suit = 3;
		  hand[i].rank = 11;
	  }
  }
  
  // change the rank of the trump suit. jack values value (2, 8 ,14 ,20)
  public void changeRank(Card hand[])
  {
	  for(int i = 0; i <= 4; i++)
	  {
		  if(hand[i].trump == 1)
		  {
			  if(hand[i].rank == 0)
			  {
				  hand[i].rank = 6; 
			  }
			  
			  if(hand[i].rank == 1)
			  {
				  hand[i].rank = 7; 
			  }
			  
			  if(hand[i].rank == 2)
			  {
				  hand[i].rank = 12; 
			  }
			  
			  if(hand[i].rank == 3)
			  {
				  hand[i].rank = 8;
			  }
			  
			  if(hand[i].rank == 4)
			  {
				  hand[i].rank = 9;
			  }
			  
			  if(hand[i].rank == 5)
			  {
				  hand[i].rank = 10;
			  }
		  }
	  }
  }
  
  public int trumpValue()
  {
	  return trump;
  }
	 
  public int getSuit() 
    {
       return suit;
    }
	 
}